import book.Book;
import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class BookSystem {

    public BookList bookList = new BookList();
    public User login() {
        System.out.println("请输入你的姓名：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();


        while (true) {
            System.out.println("请输入你的身份 1：管理员 2：普通用户");
            String choice = sc.nextLine();

            //坑：如果用户胡乱输入怎么办？
            if(choice.equals("1")) {
                return new AdminUser(name);
            }else if(choice.equals("2")){
                return new NormalUser(name);
            }else{
                System.out.println("非法输入，请您重新输入");
            }
        }
    }

    public static void main(String[] args) {
         BookSystem bookSystem = new BookSystem();
         User user = bookSystem.login();

        while (true) {
            int input = user.menu();
            user.operations[input].work(bookSystem.bookList);

        }

    }
}
